//
//  SVisitorViewController.swift
//  SWeiboBoom
//
//  Created by Angus.丶 ShangYang on 16/8/9.
//  Copyright © 2016年 Angus_Shyang. All rights reserved.
//

import UIKit

class SVisitorViewController: UIViewController {

    //判断用户是否登录
    var isLogin:Bool = false
    
    //访客视图view
    var visitorView:SVisitorView?
    
    override func loadView() {
        if isLogin{
            super.loadView()
        }else{
            setupVisitorView()
        }
    }
    
    //MARK: - 设置访客视图
    func setupVisitorView(){
        setupNav()
        visitorView = SVisitorView()
        
        //闭包的实例化 02 
        visitorView?.closure = {
            
            //04 
            self.loginAction()
        }
        
        view = visitorView
    }
    
    //设置导航
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册",style: UIBarButtonItemStyle.Plain,target: self,action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录",style: UIBarButtonItemStyle.Plain,target: self,action: "loginAction")
    }
    
    //MARK: - 监听方法
    func loginAction(){
//        print("登录和注册按钮点击")
        let oauthVc = SOAuthViewController()
        presentViewController(UINavigationController(rootViewController:oauthVc), animated: true, completion: nil)
        
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
}
